{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1ac91c6c",
   "metadata": {
    "origin_pos": 0
   },
   "source": [
    "# RMSProp\n",
    ":label:`sec_rmsprop`\n",
    "\n",
    "\n",
    "One of the key issues in :numref:`sec_adagrad` is that the learning rate decreases at a predefined schedule of effectively $\\mathcal{O}(t^{-\\frac{1}{2}})$. While this is generally appropriate for convex problems, it might not be ideal for nonconvex ones, such as those encountered in deep learning. Yet, the coordinate-wise adaptivity of Adagrad is highly desirable as a preconditioner.\n",
    "\n",
    ":citet:`Tieleman.Hinton.2012` proposed the RMSProp algorithm as a simple fix to decouple rate scheduling from coordinate-adaptive learning rates. The issue is that Adagrad accumulates the squares of the gradient $\\mathbf{g}_t$ into a state vector $\\mathbf{s}_t = \\mathbf{s}_{t-1} + \\mathbf{g}_t^2$. As a result $\\mathbf{s}_t$ keeps on growing without bound due to the lack of normalization, essentially linearly as the algorithm converges.\n",
    "\n",
    "One way of fixing this problem would be to use $\\mathbf{s}_t / t$. For reasonable distributions of $\\mathbf{g}_t$ this will converge. Unfortunately it might take a very long time until the limit behavior starts to matter since the procedure remembers the full trajectory of values. An alternative is to use a leaky average in the same way we used in the momentum method, i.e., $\\mathbf{s}_t \\leftarrow \\gamma \\mathbf{s}_{t-1} + (1-\\gamma) \\mathbf{g}_t^2$ for some parameter $\\gamma > 0$. Keeping all other parts unchanged yields RMSProp.\n",
    "\n",
    "## The Algorithm\n",
    "\n",
    "Let's write out the equations in detail.\n",
    "\n",
    "$$\\begin{aligned}\n",
    "    \\mathbf{s}_t & \\leftarrow \\gamma \\mathbf{s}_{t-1} + (1 - \\gamma) \\mathbf{g}_t^2, \\\\\n",
    "    \\mathbf{x}_t & \\leftarrow \\mathbf{x}_{t-1} - \\frac{\\eta}{\\sqrt{\\mathbf{s}_t + \\epsilon}} \\odot \\mathbf{g}_t.\n",
    "\\end{aligned}$$\n",
    "\n",
    "The constant $\\epsilon > 0$ is typically set to $10^{-6}$ to ensure that we do not suffer from division by zero or overly large step sizes. Given this expansion we are now free to control the learning rate $\\eta$ independently of the scaling that is applied on a per-coordinate basis. In terms of leaky averages we can apply the same reasoning as previously applied in the case of the momentum method. Expanding the definition of $\\mathbf{s}_t$ yields\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "\\mathbf{s}_t & = (1 - \\gamma) \\mathbf{g}_t^2 + \\gamma \\mathbf{s}_{t-1} \\\\\n",
    "& = (1 - \\gamma) \\left(\\mathbf{g}_t^2 + \\gamma \\mathbf{g}_{t-1}^2 + \\gamma^2 \\mathbf{g}_{t-2} + \\ldots, \\right).\n",
    "\\end{aligned}\n",
    "$$\n",
    "\n",
    "As before in :numref:`sec_momentum` we use $1 + \\gamma + \\gamma^2 + \\ldots, = \\frac{1}{1-\\gamma}$. Hence the sum of weights is normalized to $1$ with a half-life time of an observation of $\\gamma^{-1}$. Let's visualize the weights for the past 40 time steps for various choices of $\\gamma$.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e0909b3e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-08-18T19:38:18.653539Z",
     "iopub.status.busy": "2023-08-18T19:38:18.653217Z",
     "iopub.status.idle": "2023-08-18T19:38:22.412302Z",
     "shell.execute_reply": "2023-08-18T19:38:22.410946Z"
    },
    "origin_pos": 2,
    "tab": [
     "pytorch"
    ]
   },
   "outputs": [],
   "source": [
    "import math\n",
    "import torch\n",
    "from d2l import torch as d2l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d135b008",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-08-18T19:38:22.423079Z",
     "iopub.status.busy": "2023-08-18T19:38:22.419951Z",
     "iopub.status.idle": "2023-08-18T19:38:22.671490Z",
     "shell.execute_reply": "2023-08-18T19:38:22.670027Z"
    },
    "origin_pos": 4,
    "tab": [
     "pytorch"
    ]
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"234.6408pt\" height=\"183.35625pt\" viewBox=\"0 0 234.6408 183.35625\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2023-08-18T19:38:22.625094</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.7.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 183.35625 \n",
       "L 234.6408 183.35625 \n",
       "L 234.6408 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 30.103125 145.8 \n",
       "L 225.403125 145.8 \n",
       "L 225.403125 7.2 \n",
       "L 30.103125 7.2 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"m3ccc4e79cf\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m3ccc4e79cf\" x=\"38.980398\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(35.799148 160.398438) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m3ccc4e79cf\" x=\"84.504873\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 10 -->\n",
       "      <g transform=\"translate(78.142373 160.398438) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m3ccc4e79cf\" x=\"130.029349\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 20 -->\n",
       "      <g transform=\"translate(123.666849 160.398438) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m3ccc4e79cf\" x=\"175.553824\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 30 -->\n",
       "      <g transform=\"translate(169.191324 160.398438) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m3ccc4e79cf\" x=\"221.0783\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 40 -->\n",
       "      <g transform=\"translate(214.7158 160.398438) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_6\">\n",
       "     <!-- time -->\n",
       "     <g transform=\"translate(116.457031 174.076563) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-74\" d=\"M 1172 4494 \n",
       "L 1172 3500 \n",
       "L 2356 3500 \n",
       "L 2356 3053 \n",
       "L 1172 3053 \n",
       "L 1172 1153 \n",
       "Q 1172 725 1289 603 \n",
       "Q 1406 481 1766 481 \n",
       "L 2356 481 \n",
       "L 2356 0 \n",
       "L 1766 0 \n",
       "Q 1100 0 847 248 \n",
       "Q 594 497 594 1153 \n",
       "L 594 3053 \n",
       "L 172 3053 \n",
       "L 172 3500 \n",
       "L 594 3500 \n",
       "L 594 4494 \n",
       "L 1172 4494 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-69\" d=\"M 603 3500 \n",
       "L 1178 3500 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 3500 \n",
       "z\n",
       "M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 4134 \n",
       "L 603 4134 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6d\" d=\"M 3328 2828 \n",
       "Q 3544 3216 3844 3400 \n",
       "Q 4144 3584 4550 3584 \n",
       "Q 5097 3584 5394 3201 \n",
       "Q 5691 2819 5691 2113 \n",
       "L 5691 0 \n",
       "L 5113 0 \n",
       "L 5113 2094 \n",
       "Q 5113 2597 4934 2840 \n",
       "Q 4756 3084 4391 3084 \n",
       "Q 3944 3084 3684 2787 \n",
       "Q 3425 2491 3425 1978 \n",
       "L 3425 0 \n",
       "L 2847 0 \n",
       "L 2847 2094 \n",
       "Q 2847 2600 2669 2842 \n",
       "Q 2491 3084 2119 3084 \n",
       "Q 1678 3084 1418 2786 \n",
       "Q 1159 2488 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1356 3278 1631 3431 \n",
       "Q 1906 3584 2284 3584 \n",
       "Q 2666 3584 2933 3390 \n",
       "Q 3200 3197 3328 2828 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" x=\"39.208984\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6d\" x=\"66.992188\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"164.404297\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <defs>\n",
       "       <path id=\"m5f334474d9\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m5f334474d9\" x=\"30.103125\" y=\"139.500115\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.0 -->\n",
       "      <g transform=\"translate(7.2 143.299333) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m5f334474d9\" x=\"30.103125\" y=\"97.500076\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 0.1 -->\n",
       "      <g transform=\"translate(7.2 101.299295) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m5f334474d9\" x=\"30.103125\" y=\"55.500038\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 0.2 -->\n",
       "      <g transform=\"translate(7.2 59.299257) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m5f334474d9\" x=\"30.103125\" y=\"13.5\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 0.3 -->\n",
       "      <g transform=\"translate(7.2 17.299219) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_10\">\n",
       "    <path d=\"M 38.980398 118.500096 \n",
       "L 43.532845 119.550096 \n",
       "L 48.085293 120.547597 \n",
       "L 52.63774 121.495223 \n",
       "L 57.190188 122.395468 \n",
       "L 61.742635 123.2507 \n",
       "L 66.295083 124.063171 \n",
       "L 70.847531 124.835018 \n",
       "L 75.399978 125.568273 \n",
       "L 79.952426 126.264865 \n",
       "L 84.504873 126.926627 \n",
       "L 89.057321 127.555302 \n",
       "L 93.609768 128.152542 \n",
       "L 98.162216 128.719921 \n",
       "L 102.714663 129.258931 \n",
       "L 107.267111 129.77099 \n",
       "L 111.819559 130.257446 \n",
       "L 116.372006 130.71958 \n",
       "L 120.924454 131.158606 \n",
       "L 125.476901 131.575682 \n",
       "L 130.029349 131.971903 \n",
       "L 134.581796 132.348314 \n",
       "L 139.134244 132.705904 \n",
       "L 143.686691 133.045615 \n",
       "L 148.239139 133.36834 \n",
       "L 152.791587 133.674928 \n",
       "L 157.344034 133.966188 \n",
       "L 161.896482 134.242884 \n",
       "L 166.448929 134.505745 \n",
       "L 171.001377 134.755464 \n",
       "L 175.553824 134.992696 \n",
       "L 180.106272 135.218067 \n",
       "L 184.658719 135.43217 \n",
       "L 189.211167 135.635567 \n",
       "L 193.763615 135.828794 \n",
       "L 198.316062 136.01236 \n",
       "L 202.86851 136.186748 \n",
       "L 207.420957 136.352416 \n",
       "L 211.973405 136.509801 \n",
       "L 216.525852 136.659317 \n",
       "\" clip-path=\"url(#p71619c6a50)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_11\">\n",
       "    <path d=\"M 38.980398 97.500076 \n",
       "L 43.532845 101.70008 \n",
       "L 48.085293 105.480084 \n",
       "L 52.63774 108.882087 \n",
       "L 57.190188 111.94389 \n",
       "L 61.742635 114.699512 \n",
       "L 66.295083 117.179572 \n",
       "L 70.847531 119.411627 \n",
       "L 75.399978 121.420475 \n",
       "L 79.952426 123.228439 \n",
       "L 84.504873 124.855607 \n",
       "L 89.057321 126.320058 \n",
       "L 93.609768 127.638063 \n",
       "L 98.162216 128.824268 \n",
       "L 102.714663 129.891853 \n",
       "L 107.267111 130.852679 \n",
       "L 111.819559 131.717423 \n",
       "L 116.372006 132.495692 \n",
       "L 120.924454 133.196134 \n",
       "L 125.476901 133.826532 \n",
       "L 130.029349 134.39389 \n",
       "L 134.581796 134.904513 \n",
       "L 139.134244 135.364073 \n",
       "L 143.686691 135.777677 \n",
       "L 148.239139 136.149921 \n",
       "L 152.791587 136.48494 \n",
       "L 157.344034 136.786458 \n",
       "L 161.896482 137.057823 \n",
       "L 166.448929 137.302053 \n",
       "L 171.001377 137.521859 \n",
       "L 175.553824 137.719684 \n",
       "L 180.106272 137.897727 \n",
       "L 184.658719 138.057966 \n",
       "L 189.211167 138.202181 \n",
       "L 193.763615 138.331974 \n",
       "L 198.316062 138.448788 \n",
       "L 202.86851 138.553921 \n",
       "L 207.420957 138.64854 \n",
       "L 211.973405 138.733698 \n",
       "L 216.525852 138.810339 \n",
       "\" clip-path=\"url(#p71619c6a50)\" style=\"fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_12\">\n",
       "    <path d=\"M 38.980398 55.500038 \n",
       "L 43.532845 72.300053 \n",
       "L 48.085293 85.740066 \n",
       "L 52.63774 96.492075 \n",
       "L 57.190188 105.093683 \n",
       "L 61.742635 111.97497 \n",
       "L 66.295083 117.479999 \n",
       "L 70.847531 121.884022 \n",
       "L 75.399978 125.40724 \n",
       "L 79.952426 128.225815 \n",
       "L 84.504873 130.480675 \n",
       "L 89.057321 132.284563 \n",
       "L 93.609768 133.727673 \n",
       "L 98.162216 134.882162 \n",
       "L 102.714663 135.805752 \n",
       "L 107.267111 136.544625 \n",
       "L 111.819559 137.135723 \n",
       "L 116.372006 137.608601 \n",
       "L 120.924454 137.986904 \n",
       "L 125.476901 138.289546 \n",
       "L 130.029349 138.53166 \n",
       "L 134.581796 138.725351 \n",
       "L 139.134244 138.880303 \n",
       "L 143.686691 139.004266 \n",
       "L 148.239139 139.103435 \n",
       "L 152.791587 139.182771 \n",
       "L 157.344034 139.24624 \n",
       "L 161.896482 139.297015 \n",
       "L 166.448929 139.337635 \n",
       "L 171.001377 139.370131 \n",
       "L 175.553824 139.396128 \n",
       "L 180.106272 139.416925 \n",
       "L 184.658719 139.433563 \n",
       "L 189.211167 139.446873 \n",
       "L 193.763615 139.457522 \n",
       "L 198.316062 139.46604 \n",
       "L 202.86851 139.472855 \n",
       "L 207.420957 139.478307 \n",
       "L 211.973405 139.482668 \n",
       "L 216.525852 139.486158 \n",
       "\" clip-path=\"url(#p71619c6a50)\" style=\"fill: none; stroke: #2ca02c; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_13\">\n",
       "    <path d=\"M 38.980398 13.5 \n",
       "L 43.532845 51.300034 \n",
       "L 48.085293 77.760058 \n",
       "L 52.63774 96.282075 \n",
       "L 57.190188 109.247487 \n",
       "L 61.742635 118.323275 \n",
       "L 66.295083 124.676327 \n",
       "L 70.847531 129.123463 \n",
       "L 75.399978 132.236459 \n",
       "L 79.952426 134.415555 \n",
       "L 84.504873 135.940923 \n",
       "L 89.057321 137.008681 \n",
       "L 93.609768 137.756111 \n",
       "L 98.162216 138.279312 \n",
       "L 102.714663 138.645553 \n",
       "L 107.267111 138.901921 \n",
       "L 111.819559 139.081379 \n",
       "L 116.372006 139.207 \n",
       "L 120.924454 139.294934 \n",
       "L 125.476901 139.356488 \n",
       "L 130.029349 139.399576 \n",
       "L 134.581796 139.429738 \n",
       "L 139.134244 139.450851 \n",
       "L 143.686691 139.46563 \n",
       "L 148.239139 139.475975 \n",
       "L 152.791587 139.483217 \n",
       "L 157.344034 139.488286 \n",
       "L 161.896482 139.491835 \n",
       "L 166.448929 139.494319 \n",
       "L 171.001377 139.496058 \n",
       "L 175.553824 139.497275 \n",
       "L 180.106272 139.498127 \n",
       "L 184.658719 139.498723 \n",
       "L 189.211167 139.49914 \n",
       "L 193.763615 139.499433 \n",
       "L 198.316062 139.499637 \n",
       "L 202.86851 139.49978 \n",
       "L 207.420957 139.499881 \n",
       "L 211.973405 139.499951 \n",
       "L 216.525852 139.5 \n",
       "\" clip-path=\"url(#p71619c6a50)\" style=\"fill: none; stroke: #d62728; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 30.103125 145.8 \n",
       "L 30.103125 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 225.403125 145.8 \n",
       "L 225.403125 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 30.103125 145.8 \n",
       "L 225.403125 145.8 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 30.103125 7.2 \n",
       "L 225.403125 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p71619c6a50\">\n",
       "   <rect x=\"30.103125\" y=\"7.2\" width=\"195.3\" height=\"138.6\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 350x250 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "d2l.set_figsize()\n",
    "gammas = [0.95, 0.9, 0.8, 0.7]\n",
    "for gamma in gammas:\n",
    "    x = torch.arange(40).detach().numpy()\n",
    "    d2l.plt.plot(x, (1-gamma) * gamma ** x, label=f'gamma = {gamma:.2f}')\n",
    "d2l.plt.xlabel('time');"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ad9385f",
   "metadata": {
    "origin_pos": 5
   },
   "source": [
    "## Implementation from Scratch\n",
    "\n",
    "As before we use the quadratic function $f(\\mathbf{x})=0.1x_1^2+2x_2^2$ to observe the trajectory of RMSProp. Recall that in :numref:`sec_adagrad`, when we used Adagrad with a learning rate of 0.4, the variables moved only very slowly in the later stages of the algorithm since the learning rate decreased too quickly. Since $\\eta$ is controlled separately this does not happen with RMSProp.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "186c7b34",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-08-18T19:38:22.683908Z",
     "iopub.status.busy": "2023-08-18T19:38:22.678341Z",
     "iopub.status.idle": "2023-08-18T19:38:22.902749Z",
     "shell.execute_reply": "2023-08-18T19:38:22.901714Z"
    },
    "origin_pos": 6,
    "tab": [
     "pytorch"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 20, x1: -0.010599, x2: 0.000000\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"245.120313pt\" height=\"183.35625pt\" viewBox=\"0 0 245.120313 183.35625\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2023-08-18T19:38:22.856155</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.7.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 183.35625 \n",
       "L 245.120313 183.35625 \n",
       "L 245.120313 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 42.620312 145.8 \n",
       "L 237.920313 145.8 \n",
       "L 237.920313 7.2 \n",
       "L 42.620312 7.2 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"mdc9b80d948\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdc9b80d948\" x=\"88.39375\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- −4 -->\n",
       "      <g transform=\"translate(81.022656 160.398438) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2212\" d=\"M 678 2272 \n",
       "L 4684 2272 \n",
       "L 4684 1741 \n",
       "L 678 1741 \n",
       "L 678 2272 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdc9b80d948\" x=\"149.425\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- −2 -->\n",
       "      <g transform=\"translate(142.053907 160.398438) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdc9b80d948\" x=\"210.456251\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(207.275001 160.398438) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_4\">\n",
       "     <!-- x1 -->\n",
       "     <g transform=\"translate(134.129687 174.076563) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-78\" d=\"M 3513 3500 \n",
       "L 2247 1797 \n",
       "L 3578 0 \n",
       "L 2900 0 \n",
       "L 1881 1375 \n",
       "L 863 0 \n",
       "L 184 0 \n",
       "L 1544 1831 \n",
       "L 300 3500 \n",
       "L 978 3500 \n",
       "L 1906 2253 \n",
       "L 2834 3500 \n",
       "L 3513 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-31\" x=\"59.179688\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <defs>\n",
       "       <path id=\"m2954e1ebc9\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2954e1ebc9\" x=\"42.620312\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- −3 -->\n",
       "      <g transform=\"translate(20.878125 149.599219) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2954e1ebc9\" x=\"42.620312\" y=\"110.261538\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- −2 -->\n",
       "      <g transform=\"translate(20.878125 114.060757) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2954e1ebc9\" x=\"42.620312\" y=\"74.723076\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- −1 -->\n",
       "      <g transform=\"translate(20.878125 78.522295) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2954e1ebc9\" x=\"42.620312\" y=\"39.184615\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(29.257812 42.983833) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_9\">\n",
       "     <!-- x2 -->\n",
       "     <g transform=\"translate(14.798437 82.640625) rotate(-90) scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-32\" x=\"59.179688\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_8\">\n",
       "    <path d=\"M 57.878125 110.261538 \n",
       "L 96.477484 65.308548 \n",
       "L 120.357142 49.068785 \n",
       "L 138.043262 42.658188 \n",
       "L 152.011133 40.286769 \n",
       "L 163.368488 39.493747 \n",
       "L 172.726062 39.259292 \n",
       "L 180.468975 39.199591 \n",
       "L 186.866078 39.18697 \n",
       "L 192.121325 39.184878 \n",
       "L 196.400251 39.184631 \n",
       "L 199.844228 39.184615 \n",
       "L 202.578132 39.184615 \n",
       "L 204.714224 39.184615 \n",
       "L 206.353866 39.184615 \n",
       "L 207.58804 39.184615 \n",
       "L 208.497344 39.184615 \n",
       "L 209.151871 39.184615 \n",
       "L 209.611244 39.184615 \n",
       "L 209.924923 39.184615 \n",
       "L 210.132826 39.184615 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    <defs>\n",
       "     <path id=\"md6f0ea40b7\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #ff7f0e\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#pfc93cbf038)\">\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"57.878125\" y=\"110.261538\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"96.477484\" y=\"65.308548\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"120.357142\" y=\"49.068785\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"138.043262\" y=\"42.658188\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"152.011133\" y=\"40.286769\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"163.368488\" y=\"39.493747\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"172.726062\" y=\"39.259292\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"180.468975\" y=\"39.199591\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"186.866078\" y=\"39.18697\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"192.121325\" y=\"39.184878\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"196.400251\" y=\"39.184631\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"199.844228\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"202.578132\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"204.714224\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"206.353866\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"207.58804\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"208.497344\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"209.151871\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"209.611244\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"209.924923\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "     <use xlink:href=\"#md6f0ea40b7\" x=\"210.132826\" y=\"39.184615\" style=\"fill: #ff7f0e; stroke: #ff7f0e\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\"/>\n",
       "   <g id=\"PathCollection_2\">\n",
       "    <path d=\"M 97.100868 7.2 \n",
       "L 94.496869 7.868961 \n",
       "L 91.44531 8.673801 \n",
       "L 88.393757 9.499545 \n",
       "L 85.342191 10.346198 \n",
       "L 83.908323 10.753845 \n",
       "L 82.290631 11.275074 \n",
       "L 79.239071 12.281998 \n",
       "L 76.187512 13.312611 \n",
       "L 73.307377 14.307692 \n",
       "L 73.135938 14.376037 \n",
       "L 70.084378 15.61988 \n",
       "L 67.032818 16.891062 \n",
       "L 64.752171 17.861537 \n",
       "L 63.981244 18.249232 \n",
       "L 60.929685 19.816153 \n",
       "L 57.878125 21.415384 \n",
       "L 57.878125 21.415384 \n",
       "L 54.826565 23.409482 \n",
       "L 52.48604 24.96923 \n",
       "L 51.775006 25.578453 \n",
       "L 48.723432 28.243853 \n",
       "L 48.409729 28.523076 \n",
       "L 45.671872 31.93477 \n",
       "L 45.55989 32.076922 \n",
       "L 43.880133 35.630769 \n",
       "L 43.320214 39.184616 \n",
       "L 43.880133 42.738462 \n",
       "L 45.55989 46.292308 \n",
       "L 45.671872 46.43446 \n",
       "L 48.409729 49.846154 \n",
       "L 48.723432 50.125377 \n",
       "L 51.775006 52.790777 \n",
       "L 52.486042 53.400001 \n",
       "L 54.826565 54.959745 \n",
       "L 57.878125 56.953846 \n",
       "L 57.878125 56.953846 \n",
       "L 60.929685 58.553076 \n",
       "L 63.981244 60.119998 \n",
       "L 64.752171 60.507693 \n",
       "L 67.032818 61.478167 \n",
       "L 70.084378 62.749349 \n",
       "L 73.135938 63.993193 \n",
       "L 73.307377 64.061538 \n",
       "L 76.187512 65.056618 \n",
       "L 79.239071 66.087232 \n",
       "L 82.290631 67.094156 \n",
       "L 83.908319 67.615382 \n",
       "L 85.342191 68.02303 \n",
       "L 88.393757 68.869685 \n",
       "L 91.44531 69.695427 \n",
       "L 94.496869 70.500269 \n",
       "L 97.100868 71.169229 \n",
       "L 97.548436 71.272105 \n",
       "L 100.599996 71.954818 \n",
       "L 103.651563 72.618826 \n",
       "L 106.703122 73.264128 \n",
       "L 109.754682 73.890726 \n",
       "L 112.806249 74.498621 \n",
       "L 113.968755 74.723076 \n",
       "L 115.857816 75.053077 \n",
       "L 118.909375 75.56923 \n",
       "L 121.960942 76.068463 \n",
       "L 125.012502 76.55077 \n",
       "L 128.064069 77.016155 \n",
       "L 131.115628 77.464616 \n",
       "L 134.167188 77.896154 \n",
       "L 136.969651 78.276924 \n",
       "L 137.218755 78.307826 \n",
       "L 140.270314 78.670936 \n",
       "L 143.321874 79.018595 \n",
       "L 146.373441 79.350803 \n",
       "L 149.425 79.667558 \n",
       "L 152.476564 79.968862 \n",
       "L 155.528127 80.254716 \n",
       "L 158.57969 80.525117 \n",
       "L 161.631253 80.780066 \n",
       "L 164.682813 81.019566 \n",
       "L 167.734376 81.243611 \n",
       "L 170.785939 81.452208 \n",
       "L 173.837499 81.645351 \n",
       "L 176.889062 81.823043 \n",
       "L 177.034329 81.830766 \n",
       "L 179.940626 81.972923 \n",
       "L 182.992189 82.107968 \n",
       "L 186.04375 82.228801 \n",
       "L 189.095313 82.335415 \n",
       "L 192.146877 82.427815 \n",
       "L 195.198438 82.505999 \n",
       "L 198.250001 82.569969 \n",
       "L 201.301564 82.619722 \n",
       "L 204.353126 82.655262 \n",
       "L 207.404689 82.676585 \n",
       "L 210.456251 82.683692 \n",
       "L 213.507813 82.676585 \n",
       "L 216.559376 82.655262 \n",
       "L 219.610939 82.619722 \n",
       "L 222.662501 82.569969 \n",
       "L 225.714063 82.505999 \n",
       "L 228.765626 82.427815 \n",
       "L 231.817188 82.335415 \n",
       "L 234.868751 82.228801 \n",
       "L 237.920313 82.107968 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_3\">\n",
       "    <path d=\"M 42.620312 82.505999 \n",
       "L 45.671872 83.280739 \n",
       "L 48.723432 84.041258 \n",
       "L 51.775006 84.78757 \n",
       "L 54.263642 85.384613 \n",
       "L 54.826565 85.509659 \n",
       "L 57.878125 86.174359 \n",
       "L 60.929685 86.825897 \n",
       "L 63.981244 87.464272 \n",
       "L 67.032818 88.089488 \n",
       "L 70.084378 88.701539 \n",
       "L 71.29158 88.93846 \n",
       "L 73.135938 89.275465 \n",
       "L 76.187512 89.820797 \n",
       "L 79.239071 90.353873 \n",
       "L 82.290631 90.874696 \n",
       "L 85.342191 91.383263 \n",
       "L 88.393757 91.879576 \n",
       "L 91.44531 92.363634 \n",
       "L 92.277553 92.492307 \n",
       "L 94.496869 92.813298 \n",
       "L 97.548436 93.243201 \n",
       "L 100.599996 93.661637 \n",
       "L 103.651563 94.06861 \n",
       "L 106.703122 94.464117 \n",
       "L 109.754682 94.848161 \n",
       "L 112.806249 95.220742 \n",
       "L 115.857816 95.58186 \n",
       "L 118.909375 95.931512 \n",
       "L 119.943828 96.046154 \n",
       "L 121.960942 96.256152 \n",
       "L 125.012502 96.563076 \n",
       "L 128.064069 96.859229 \n",
       "L 131.115628 97.144614 \n",
       "L 134.167188 97.41923 \n",
       "L 137.218755 97.683078 \n",
       "L 140.270314 97.936154 \n",
       "L 143.321874 98.17846 \n",
       "L 146.373441 98.41 \n",
       "L 149.425 98.630769 \n",
       "L 152.476564 98.840769 \n",
       "L 155.528127 99.040001 \n",
       "L 158.57969 99.228461 \n",
       "L 161.631253 99.406154 \n",
       "L 164.682813 99.573078 \n",
       "L 165.20896 99.600001 \n",
       "L 167.734376 99.721846 \n",
       "L 170.785939 99.858923 \n",
       "L 173.837499 99.985846 \n",
       "L 176.889062 100.102617 \n",
       "L 179.940626 100.209232 \n",
       "L 182.992189 100.305693 \n",
       "L 186.04375 100.392 \n",
       "L 189.095313 100.468155 \n",
       "L 192.146877 100.534155 \n",
       "L 195.198438 100.59 \n",
       "L 198.250001 100.635694 \n",
       "L 201.301564 100.671232 \n",
       "L 204.353126 100.696615 \n",
       "L 207.404689 100.711847 \n",
       "L 210.456251 100.716923 \n",
       "L 213.507813 100.711847 \n",
       "L 216.559376 100.696615 \n",
       "L 219.610939 100.671232 \n",
       "L 222.662501 100.635694 \n",
       "L 225.714063 100.59 \n",
       "L 228.765626 100.534155 \n",
       "L 231.817188 100.468155 \n",
       "L 234.868751 100.392 \n",
       "L 237.920313 100.305693 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_4\">\n",
       "    <path d=\"M 42.620312 100.589999 \n",
       "L 45.671872 101.143384 \n",
       "L 48.723432 101.686614 \n",
       "L 51.775006 102.219694 \n",
       "L 54.826565 102.742616 \n",
       "L 57.27387 103.153848 \n",
       "L 57.878125 103.249896 \n",
       "L 60.929685 103.725343 \n",
       "L 63.981244 104.191185 \n",
       "L 67.032818 104.647423 \n",
       "L 70.084378 105.094054 \n",
       "L 73.135938 105.53108 \n",
       "L 76.187512 105.958505 \n",
       "L 79.239071 106.376322 \n",
       "L 81.716227 106.707695 \n",
       "L 82.290631 106.780594 \n",
       "L 85.342191 107.158756 \n",
       "L 88.393757 107.527811 \n",
       "L 91.44531 107.88775 \n",
       "L 94.496869 108.23858 \n",
       "L 97.548436 108.580295 \n",
       "L 100.599996 108.912898 \n",
       "L 103.651563 109.236389 \n",
       "L 106.703122 109.550769 \n",
       "L 109.754682 109.856036 \n",
       "L 112.806249 110.152188 \n",
       "L 113.968764 110.261538 \n",
       "L 115.857816 110.430561 \n",
       "L 118.909375 110.694936 \n",
       "L 121.960942 110.950639 \n",
       "L 125.012502 111.197671 \n",
       "L 128.064069 111.43604 \n",
       "L 131.115628 111.665742 \n",
       "L 134.167188 111.886772 \n",
       "L 137.218755 112.099135 \n",
       "L 140.270314 112.302831 \n",
       "L 143.321874 112.497859 \n",
       "L 146.373441 112.68422 \n",
       "L 149.425 112.861914 \n",
       "L 152.476564 113.030936 \n",
       "L 155.528127 113.191291 \n",
       "L 158.57969 113.342983 \n",
       "L 161.631253 113.486004 \n",
       "L 164.682813 113.620353 \n",
       "L 167.734376 113.746039 \n",
       "L 169.542874 113.81539 \n",
       "L 170.785939 113.86084 \n",
       "L 173.837499 113.964148 \n",
       "L 176.889062 114.059192 \n",
       "L 179.940626 114.145972 \n",
       "L 182.992189 114.224487 \n",
       "L 186.04375 114.294739 \n",
       "L 189.095313 114.356726 \n",
       "L 192.146877 114.410445 \n",
       "L 195.198438 114.455904 \n",
       "L 198.250001 114.493094 \n",
       "L 201.301564 114.522021 \n",
       "L 204.353126 114.542683 \n",
       "L 207.404689 114.555078 \n",
       "L 210.456251 114.559212 \n",
       "L 213.507813 114.555078 \n",
       "L 216.559376 114.542683 \n",
       "L 219.610939 114.522021 \n",
       "L 222.662501 114.493094 \n",
       "L 225.714063 114.455904 \n",
       "L 228.765626 114.410445 \n",
       "L 231.817188 114.356726 \n",
       "L 234.868751 114.294739 \n",
       "L 237.920313 114.224487 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_5\">\n",
       "    <path d=\"M 42.620312 114.455904 \n",
       "L 45.671872 114.90633 \n",
       "L 48.723432 115.348496 \n",
       "L 51.775006 115.782398 \n",
       "L 54.826565 116.208033 \n",
       "L 57.878125 116.625402 \n",
       "L 60.929685 117.034508 \n",
       "L 63.477901 117.369232 \n",
       "L 63.981244 117.432411 \n",
       "L 67.032818 117.80754 \n",
       "L 70.084378 118.174768 \n",
       "L 73.135938 118.534104 \n",
       "L 76.187512 118.885538 \n",
       "L 79.239071 119.229076 \n",
       "L 82.290631 119.564717 \n",
       "L 85.342191 119.892461 \n",
       "L 88.393757 120.212309 \n",
       "L 91.44531 120.524255 \n",
       "L 94.496869 120.828305 \n",
       "L 95.47338 120.923075 \n",
       "L 97.548436 121.115889 \n",
       "L 100.599996 121.391879 \n",
       "L 103.651563 121.660309 \n",
       "L 106.703122 121.921177 \n",
       "L 109.754682 122.174485 \n",
       "L 112.806249 122.420228 \n",
       "L 115.857816 122.658411 \n",
       "L 118.909375 122.889036 \n",
       "L 121.960942 123.112097 \n",
       "L 125.012502 123.327593 \n",
       "L 128.064069 123.535532 \n",
       "L 131.115628 123.735911 \n",
       "L 134.167188 123.928724 \n",
       "L 137.218755 124.113977 \n",
       "L 140.270314 124.29167 \n",
       "L 143.321874 124.461801 \n",
       "L 143.605786 124.476926 \n",
       "L 146.373441 124.618353 \n",
       "L 149.425 124.767036 \n",
       "L 152.476564 124.908463 \n",
       "L 155.528127 125.042637 \n",
       "L 158.57969 125.169563 \n",
       "L 161.631253 125.289234 \n",
       "L 164.682813 125.401648 \n",
       "L 167.734376 125.506814 \n",
       "L 170.785939 125.604728 \n",
       "L 173.837499 125.695385 \n",
       "L 176.889062 125.778791 \n",
       "L 179.940626 125.854945 \n",
       "L 182.992189 125.923846 \n",
       "L 186.04375 125.985495 \n",
       "L 189.095313 126.039892 \n",
       "L 192.146877 126.087033 \n",
       "L 195.198438 126.126925 \n",
       "L 198.250001 126.159562 \n",
       "L 201.301564 126.184946 \n",
       "L 204.353126 126.203079 \n",
       "L 207.404689 126.213955 \n",
       "L 210.456251 126.217583 \n",
       "L 213.507813 126.213955 \n",
       "L 216.559376 126.203079 \n",
       "L 219.610939 126.184946 \n",
       "L 222.662501 126.159562 \n",
       "L 225.714063 126.126925 \n",
       "L 228.765626 126.087033 \n",
       "L 231.817188 126.039892 \n",
       "L 234.868751 125.985495 \n",
       "L 237.920313 125.923846 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_6\">\n",
       "    <path d=\"M 42.620312 126.126925 \n",
       "L 45.671872 126.522197 \n",
       "L 48.723432 126.91022 \n",
       "L 51.775006 127.290991 \n",
       "L 54.826565 127.664506 \n",
       "L 57.878125 128.030769 \n",
       "L 57.878125 128.030769 \n",
       "L 60.929685 128.375701 \n",
       "L 63.981244 128.713666 \n",
       "L 67.032818 129.044662 \n",
       "L 70.084378 129.368688 \n",
       "L 73.135938 129.685749 \n",
       "L 76.187512 129.995838 \n",
       "L 79.239071 130.29896 \n",
       "L 82.290631 130.595114 \n",
       "L 85.342191 130.884301 \n",
       "L 88.393757 131.166519 \n",
       "L 91.44531 131.441767 \n",
       "L 93.070112 131.584612 \n",
       "L 94.496869 131.705313 \n",
       "L 97.548436 131.956763 \n",
       "L 100.599996 132.201509 \n",
       "L 103.651563 132.43955 \n",
       "L 106.703122 132.670885 \n",
       "L 109.754682 132.895516 \n",
       "L 112.806249 133.113439 \n",
       "L 115.857816 133.324659 \n",
       "L 118.909375 133.529174 \n",
       "L 121.960942 133.726982 \n",
       "L 125.012502 133.918082 \n",
       "L 128.064069 134.102481 \n",
       "L 131.115628 134.280175 \n",
       "L 134.167188 134.45116 \n",
       "L 137.218755 134.615441 \n",
       "L 140.270314 134.773017 \n",
       "L 143.321874 134.923888 \n",
       "L 146.373441 135.068054 \n",
       "L 147.936485 135.138463 \n",
       "L 149.425 135.203077 \n",
       "L 152.476564 135.329076 \n",
       "L 155.528127 135.448613 \n",
       "L 158.57969 135.561693 \n",
       "L 161.631253 135.668308 \n",
       "L 164.682813 135.768459 \n",
       "L 167.734376 135.862153 \n",
       "L 170.785939 135.949385 \n",
       "L 173.837499 136.030153 \n",
       "L 176.889062 136.10446 \n",
       "L 179.940626 136.172306 \n",
       "L 182.992189 136.233691 \n",
       "L 186.04375 136.288614 \n",
       "L 189.095313 136.337077 \n",
       "L 192.146877 136.379075 \n",
       "L 195.198438 136.414616 \n",
       "L 198.250001 136.443692 \n",
       "L 201.301564 136.466308 \n",
       "L 204.353126 136.482462 \n",
       "L 207.404689 136.492152 \n",
       "L 210.456251 136.495384 \n",
       "L 213.507813 136.492152 \n",
       "L 216.559376 136.482462 \n",
       "L 219.610939 136.466308 \n",
       "L 222.662501 136.443692 \n",
       "L 225.714063 136.414616 \n",
       "L 228.765626 136.379075 \n",
       "L 231.817188 136.337077 \n",
       "L 234.868751 136.288614 \n",
       "L 237.920313 136.233691 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_7\">\n",
       "    <path d=\"M 42.620312 136.414613 \n",
       "L 45.671872 136.766771 \n",
       "L 48.723432 137.112458 \n",
       "L 51.775006 137.451694 \n",
       "L 54.826565 137.784465 \n",
       "L 57.878125 138.110766 \n",
       "L 60.929685 138.430616 \n",
       "L 63.477871 138.692306 \n",
       "L 63.981244 138.742187 \n",
       "L 67.032818 139.038339 \n",
       "L 70.084378 139.328259 \n",
       "L 73.135938 139.611942 \n",
       "L 76.187512 139.889394 \n",
       "L 79.239071 140.160608 \n",
       "L 82.290631 140.425588 \n",
       "L 85.342191 140.684331 \n",
       "L 88.393757 140.936841 \n",
       "L 91.44531 141.183116 \n",
       "L 94.496869 141.423157 \n",
       "L 97.548436 141.656963 \n",
       "L 100.599996 141.884534 \n",
       "L 103.651563 142.105868 \n",
       "L 105.641791 142.246157 \n",
       "L 106.703122 142.318434 \n",
       "L 109.754682 142.520218 \n",
       "L 112.806249 142.715983 \n",
       "L 115.857816 142.905721 \n",
       "L 118.909375 143.089439 \n",
       "L 121.960942 143.267132 \n",
       "L 125.012502 143.438798 \n",
       "L 128.064069 143.604445 \n",
       "L 131.115628 143.764065 \n",
       "L 134.167188 143.917665 \n",
       "L 137.218755 144.06524 \n",
       "L 140.270314 144.206794 \n",
       "L 143.321874 144.342322 \n",
       "L 146.373441 144.471825 \n",
       "L 149.425 144.595307 \n",
       "L 152.476564 144.712763 \n",
       "L 155.528127 144.8242 \n",
       "L 158.57969 144.92961 \n",
       "L 161.631253 145.028994 \n",
       "L 164.682813 145.122358 \n",
       "L 167.734376 145.209702 \n",
       "L 170.785939 145.291015 \n",
       "L 173.837499 145.366313 \n",
       "L 176.889062 145.435579 \n",
       "L 179.940626 145.498825 \n",
       "L 182.992189 145.556051 \n",
       "L 186.04375 145.607251 \n",
       "L 189.095313 145.652426 \n",
       "L 192.146877 145.69158 \n",
       "L 195.198438 145.724708 \n",
       "L 198.250001 145.75181 \n",
       "L 201.301564 145.772892 \n",
       "L 204.353126 145.787954 \n",
       "L 207.404689 145.79699 \n",
       "L 210.456251 145.8 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5\"/>\n",
       "    <path d=\"M 210.456251 145.8 \n",
       "L 213.507813 145.79699 \n",
       "L 216.559376 145.787954 \n",
       "L 219.610939 145.772892 \n",
       "L 222.662501 145.75181 \n",
       "L 225.714063 145.724708 \n",
       "L 228.765626 145.69158 \n",
       "L 231.817188 145.652426 \n",
       "L 234.868751 145.607251 \n",
       "L 237.920313 145.556051 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_8\">\n",
       "    <path d=\"M 42.620312 145.724708 \n",
       "L 43.320206 145.8 \n",
       "\" clip-path=\"url(#pfc93cbf038)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_9\"/>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 42.620312 145.8 \n",
       "L 42.620312 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 237.920313 145.8 \n",
       "L 237.920313 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 42.620312 145.8 \n",
       "L 237.920313 145.8 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 42.620312 7.2 \n",
       "L 237.920313 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pfc93cbf038\">\n",
       "   <rect x=\"42.620312\" y=\"7.2\" width=\"195.3\" height=\"138.6\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 350x250 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def rmsprop_2d(x1, x2, s1, s2):\n",
    "    g1, g2, eps = 0.2 * x1, 4 * x2, 1e-6\n",
    "    s1 = gamma * s1 + (1 - gamma) * g1 ** 2\n",
    "    s2 = gamma * s2 + (1 - gamma) * g2 ** 2\n",
    "    x1 -= eta / math.sqrt(s1 + eps) * g1\n",
    "    x2 -= eta / math.sqrt(s2 + eps) * g2\n",
    "    return x1, x2, s1, s2\n",
    "\n",
    "def f_2d(x1, x2):\n",
    "    return 0.1 * x1 ** 2 + 2 * x2 ** 2\n",
    "\n",
    "eta, gamma = 0.4, 0.9\n",
    "d2l.show_trace_2d(f_2d, d2l.train_2d(rmsprop_2d))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "963e122d",
   "metadata": {
    "origin_pos": 7
   },
   "source": [
    "Next, we implement RMSProp to be used in a deep network. This is equally straightforward.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e8e0e3f0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-08-18T19:38:22.908239Z",
     "iopub.status.busy": "2023-08-18T19:38:22.907762Z",
     "iopub.status.idle": "2023-08-18T19:38:22.916224Z",
     "shell.execute_reply": "2023-08-18T19:38:22.915291Z"
    },
    "origin_pos": 8,
    "tab": [
     "pytorch"
    ]
   },
   "outputs": [],
   "source": [
    "def init_rmsprop_states(feature_dim):\n",
    "    s_w = torch.zeros((feature_dim, 1))\n",
    "    s_b = torch.zeros(1)\n",
    "    return (s_w, s_b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d820bd1b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-08-18T19:38:22.919668Z",
     "iopub.status.busy": "2023-08-18T19:38:22.919312Z",
     "iopub.status.idle": "2023-08-18T19:38:22.928989Z",
     "shell.execute_reply": "2023-08-18T19:38:22.924422Z"
    },
    "origin_pos": 11,
    "tab": [
     "pytorch"
    ]
   },
   "outputs": [],
   "source": [
    "def rmsprop(params, states, hyperparams):\n",
    "    gamma, eps = hyperparams['gamma'], 1e-6\n",
    "    for p, s in zip(params, states):\n",
    "        with torch.no_grad():\n",
    "            s[:] = gamma * s + (1 - gamma) * torch.square(p.grad)\n",
    "            p[:] -= hyperparams['lr'] * p.grad / torch.sqrt(s + eps)\n",
    "        p.grad.data.zero_()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c22a86d4",
   "metadata": {
    "origin_pos": 13
   },
   "source": [
    "We set the initial learning rate to 0.01 and the weighting term $\\gamma$ to 0.9. That is, $\\mathbf{s}$ aggregates on average over the past $1/(1-\\gamma) = 10$ observations of the square gradient.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "95618054",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-08-18T19:38:22.934493Z",
     "iopub.status.busy": "2023-08-18T19:38:22.934151Z",
     "iopub.status.idle": "2023-08-18T19:38:27.523745Z",
     "shell.execute_reply": "2023-08-18T19:38:27.520739Z"
    },
    "origin_pos": 14,
    "tab": [
     "pytorch"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss: 0.245, 0.245 sec/epoch\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"266.957813pt\" height=\"187.155469pt\" viewBox=\"0 0 266.957813 187.155469\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2023-08-18T19:38:27.468551</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.7.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M -0 187.155469 \n",
       "L 266.957813 187.155469 \n",
       "L 266.957813 -0 \n",
       "L -0 -0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 56.50625 149.599219 \n",
       "L 251.80625 149.599219 \n",
       "L 251.80625 10.999219 \n",
       "L 56.50625 10.999219 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path d=\"M 56.50625 149.599219 \n",
       "L 56.50625 10.999219 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\">\n",
       "      <defs>\n",
       "       <path id=\"mc9a7a954c7\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc9a7a954c7\" x=\"56.50625\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0.0 -->\n",
       "      <g transform=\"translate(48.554688 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path d=\"M 105.33125 149.599219 \n",
       "L 105.33125 10.999219 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc9a7a954c7\" x=\"105.33125\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 0.5 -->\n",
       "      <g transform=\"translate(97.379688 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path d=\"M 154.15625 149.599219 \n",
       "L 154.15625 10.999219 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc9a7a954c7\" x=\"154.15625\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 1.0 -->\n",
       "      <g transform=\"translate(146.204688 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path d=\"M 202.98125 149.599219 \n",
       "L 202.98125 10.999219 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc9a7a954c7\" x=\"202.98125\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 1.5 -->\n",
       "      <g transform=\"translate(195.029688 164.197656) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path d=\"M 251.80625 149.599219 \n",
       "L 251.80625 10.999219 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc9a7a954c7\" x=\"251.80625\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 2.0 -->\n",
       "      <g transform=\"translate(243.854688 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_6\">\n",
       "     <!-- epoch -->\n",
       "     <g transform=\"translate(138.928125 177.875781) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-70\" d=\"M 1159 525 \n",
       "L 1159 -1331 \n",
       "L 581 -1331 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "z\n",
       "M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6f\" d=\"M 1959 3097 \n",
       "Q 1497 3097 1228 2736 \n",
       "Q 959 2375 959 1747 \n",
       "Q 959 1119 1226 758 \n",
       "Q 1494 397 1959 397 \n",
       "Q 2419 397 2687 759 \n",
       "Q 2956 1122 2956 1747 \n",
       "Q 2956 2369 2687 2733 \n",
       "Q 2419 3097 1959 3097 \n",
       "z\n",
       "M 1959 3584 \n",
       "Q 2709 3584 3137 3096 \n",
       "Q 3566 2609 3566 1747 \n",
       "Q 3566 888 3137 398 \n",
       "Q 2709 -91 1959 -91 \n",
       "Q 1206 -91 779 398 \n",
       "Q 353 888 353 1747 \n",
       "Q 353 2609 779 3096 \n",
       "Q 1206 3584 1959 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-63\" d=\"M 3122 3366 \n",
       "L 3122 2828 \n",
       "Q 2878 2963 2633 3030 \n",
       "Q 2388 3097 2138 3097 \n",
       "Q 1578 3097 1268 2742 \n",
       "Q 959 2388 959 1747 \n",
       "Q 959 1106 1268 751 \n",
       "Q 1578 397 2138 397 \n",
       "Q 2388 397 2633 464 \n",
       "Q 2878 531 3122 666 \n",
       "L 3122 134 \n",
       "Q 2881 22 2623 -34 \n",
       "Q 2366 -91 2075 -91 \n",
       "Q 1284 -91 818 406 \n",
       "Q 353 903 353 1747 \n",
       "Q 353 2603 823 3093 \n",
       "Q 1294 3584 2113 3584 \n",
       "Q 2378 3584 2631 3529 \n",
       "Q 2884 3475 3122 3366 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-68\" d=\"M 3513 2113 \n",
       "L 3513 0 \n",
       "L 2938 0 \n",
       "L 2938 2094 \n",
       "Q 2938 2591 2744 2837 \n",
       "Q 2550 3084 2163 3084 \n",
       "Q 1697 3084 1428 2787 \n",
       "Q 1159 2491 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 2956 \n",
       "Q 1366 3272 1645 3428 \n",
       "Q 1925 3584 2291 3584 \n",
       "Q 2894 3584 3203 3211 \n",
       "Q 3513 2838 3513 2113 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" x=\"61.523438\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"186.181641\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-68\" x=\"241.162109\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path d=\"M 56.50625 144.26845 \n",
       "L 251.80625 144.26845 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\">\n",
       "      <defs>\n",
       "       <path id=\"m791aef8a47\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m791aef8a47\" x=\"56.50625\" y=\"144.26845\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.225 -->\n",
       "      <g transform=\"translate(20.878125 148.067668) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path d=\"M 56.50625 117.614603 \n",
       "L 251.80625 117.614603 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m791aef8a47\" x=\"56.50625\" y=\"117.614603\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 0.250 -->\n",
       "      <g transform=\"translate(20.878125 121.413822) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path d=\"M 56.50625 90.960757 \n",
       "L 251.80625 90.960757 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m791aef8a47\" x=\"56.50625\" y=\"90.960757\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 0.275 -->\n",
       "      <g transform=\"translate(20.878125 94.759976) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-37\" d=\"M 525 4666 \n",
       "L 3525 4666 \n",
       "L 3525 4397 \n",
       "L 1831 0 \n",
       "L 1172 0 \n",
       "L 2766 4134 \n",
       "L 525 4134 \n",
       "L 525 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-37\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <path d=\"M 56.50625 64.306911 \n",
       "L 251.80625 64.306911 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m791aef8a47\" x=\"56.50625\" y=\"64.306911\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 0.300 -->\n",
       "      <g transform=\"translate(20.878125 68.10613) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path d=\"M 56.50625 37.653065 \n",
       "L 251.80625 37.653065 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_20\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m791aef8a47\" x=\"56.50625\" y=\"37.653065\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 0.325 -->\n",
       "      <g transform=\"translate(20.878125 41.452284) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <path d=\"M 56.50625 10.999219 \n",
       "L 251.80625 10.999219 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_22\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m791aef8a47\" x=\"56.50625\" y=\"10.999219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 0.350 -->\n",
       "      <g transform=\"translate(20.878125 14.798438) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_13\">\n",
       "     <!-- loss -->\n",
       "     <g transform=\"translate(14.798438 89.957031) rotate(-90) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-6c\" d=\"M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-73\" d=\"M 2834 3397 \n",
       "L 2834 2853 \n",
       "Q 2591 2978 2328 3040 \n",
       "Q 2066 3103 1784 3103 \n",
       "Q 1356 3103 1142 2972 \n",
       "Q 928 2841 928 2578 \n",
       "Q 928 2378 1081 2264 \n",
       "Q 1234 2150 1697 2047 \n",
       "L 1894 2003 \n",
       "Q 2506 1872 2764 1633 \n",
       "Q 3022 1394 3022 966 \n",
       "Q 3022 478 2636 193 \n",
       "Q 2250 -91 1575 -91 \n",
       "Q 1294 -91 989 -36 \n",
       "Q 684 19 347 128 \n",
       "L 347 722 \n",
       "Q 666 556 975 473 \n",
       "Q 1284 391 1588 391 \n",
       "Q 1994 391 2212 530 \n",
       "Q 2431 669 2431 922 \n",
       "Q 2431 1156 2273 1281 \n",
       "Q 2116 1406 1581 1522 \n",
       "L 1381 1569 \n",
       "Q 847 1681 609 1914 \n",
       "Q 372 2147 372 2553 \n",
       "Q 372 3047 722 3315 \n",
       "Q 1072 3584 1716 3584 \n",
       "Q 2034 3584 2315 3537 \n",
       "Q 2597 3491 2834 3397 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"27.783203\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"88.964844\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"141.064453\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_23\">\n",
       "    <path d=\"M 69.52625 10.450564 \n",
       "L 82.54625 69.136749 \n",
       "L 95.56625 101.165224 \n",
       "L 108.58625 114.056305 \n",
       "L 121.60625 117.919138 \n",
       "L 134.62625 120.71799 \n",
       "L 147.64625 123.858913 \n",
       "L 160.66625 123.73587 \n",
       "L 173.68625 123.058955 \n",
       "L 186.70625 122.576584 \n",
       "L 199.72625 122.546957 \n",
       "L 212.74625 123.862941 \n",
       "L 225.76625 125.58065 \n",
       "L 238.78625 125.519786 \n",
       "L 251.80625 123.362484 \n",
       "\" clip-path=\"url(#pafe3767e97)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 56.50625 149.599219 \n",
       "L 56.50625 10.999219 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 251.80625 149.599219 \n",
       "L 251.80625 10.999219 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 56.50625 149.599219 \n",
       "L 251.80625 149.599219 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 56.50625 10.999219 \n",
       "L 251.80625 10.999219 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pafe3767e97\">\n",
       "   <rect x=\"56.50625\" y=\"10.999219\" width=\"195.3\" height=\"138.6\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 350x250 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data_iter, feature_dim = d2l.get_data_ch11(batch_size=10)\n",
    "d2l.train_ch11(rmsprop, init_rmsprop_states(feature_dim),\n",
    "               {'lr': 0.01, 'gamma': 0.9}, data_iter, feature_dim);"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2a8d178",
   "metadata": {
    "origin_pos": 15
   },
   "source": [
    "## Concise Implementation\n",
    "\n",
    "Since RMSProp is a rather popular algorithm it is also available in the `Trainer` instance. All we need to do is instantiate it using an algorithm named `rmsprop`, assigning $\\gamma$ to the parameter `gamma1`.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "be90a4f1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-08-18T19:38:27.530243Z",
     "iopub.status.busy": "2023-08-18T19:38:27.529340Z",
     "iopub.status.idle": "2023-08-18T19:38:35.580724Z",
     "shell.execute_reply": "2023-08-18T19:38:35.577932Z"
    },
    "origin_pos": 17,
    "tab": [
     "pytorch"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss: 0.246, 0.129 sec/epoch\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"262.1875pt\" height=\"187.155469pt\" viewBox=\"0 0 262.1875 187.155469\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2023-08-18T19:38:35.521992</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.7.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M -0 187.155469 \n",
       "L 262.1875 187.155469 \n",
       "L 262.1875 -0 \n",
       "L -0 -0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 56.50625 149.599219 \n",
       "L 251.80625 149.599219 \n",
       "L 251.80625 10.999219 \n",
       "L 56.50625 10.999219 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path d=\"M 56.50625 149.599219 \n",
       "L 56.50625 10.999219 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\">\n",
       "      <defs>\n",
       "       <path id=\"m4969a38b70\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m4969a38b70\" x=\"56.50625\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(53.325 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path d=\"M 105.33125 149.599219 \n",
       "L 105.33125 10.999219 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m4969a38b70\" x=\"105.33125\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 1 -->\n",
       "      <g transform=\"translate(102.15 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path d=\"M 154.15625 149.599219 \n",
       "L 154.15625 10.999219 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m4969a38b70\" x=\"154.15625\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 2 -->\n",
       "      <g transform=\"translate(150.975 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path d=\"M 202.98125 149.599219 \n",
       "L 202.98125 10.999219 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m4969a38b70\" x=\"202.98125\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 3 -->\n",
       "      <g transform=\"translate(199.8 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path d=\"M 251.80625 149.599219 \n",
       "L 251.80625 10.999219 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m4969a38b70\" x=\"251.80625\" y=\"149.599219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 4 -->\n",
       "      <g transform=\"translate(248.625 164.197656) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_6\">\n",
       "     <!-- epoch -->\n",
       "     <g transform=\"translate(138.928125 177.875781) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-70\" d=\"M 1159 525 \n",
       "L 1159 -1331 \n",
       "L 581 -1331 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "z\n",
       "M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6f\" d=\"M 1959 3097 \n",
       "Q 1497 3097 1228 2736 \n",
       "Q 959 2375 959 1747 \n",
       "Q 959 1119 1226 758 \n",
       "Q 1494 397 1959 397 \n",
       "Q 2419 397 2687 759 \n",
       "Q 2956 1122 2956 1747 \n",
       "Q 2956 2369 2687 2733 \n",
       "Q 2419 3097 1959 3097 \n",
       "z\n",
       "M 1959 3584 \n",
       "Q 2709 3584 3137 3096 \n",
       "Q 3566 2609 3566 1747 \n",
       "Q 3566 888 3137 398 \n",
       "Q 2709 -91 1959 -91 \n",
       "Q 1206 -91 779 398 \n",
       "Q 353 888 353 1747 \n",
       "Q 353 2609 779 3096 \n",
       "Q 1206 3584 1959 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-63\" d=\"M 3122 3366 \n",
       "L 3122 2828 \n",
       "Q 2878 2963 2633 3030 \n",
       "Q 2388 3097 2138 3097 \n",
       "Q 1578 3097 1268 2742 \n",
       "Q 959 2388 959 1747 \n",
       "Q 959 1106 1268 751 \n",
       "Q 1578 397 2138 397 \n",
       "Q 2388 397 2633 464 \n",
       "Q 2878 531 3122 666 \n",
       "L 3122 134 \n",
       "Q 2881 22 2623 -34 \n",
       "Q 2366 -91 2075 -91 \n",
       "Q 1284 -91 818 406 \n",
       "Q 353 903 353 1747 \n",
       "Q 353 2603 823 3093 \n",
       "Q 1294 3584 2113 3584 \n",
       "Q 2378 3584 2631 3529 \n",
       "Q 2884 3475 3122 3366 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-68\" d=\"M 3513 2113 \n",
       "L 3513 0 \n",
       "L 2938 0 \n",
       "L 2938 2094 \n",
       "Q 2938 2591 2744 2837 \n",
       "Q 2550 3084 2163 3084 \n",
       "Q 1697 3084 1428 2787 \n",
       "Q 1159 2491 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 2956 \n",
       "Q 1366 3272 1645 3428 \n",
       "Q 1925 3584 2291 3584 \n",
       "Q 2894 3584 3203 3211 \n",
       "Q 3513 2838 3513 2113 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" x=\"61.523438\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"186.181641\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-68\" x=\"241.162109\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path d=\"M 56.50625 144.26845 \n",
       "L 251.80625 144.26845 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\">\n",
       "      <defs>\n",
       "       <path id=\"mbcd31d84d7\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbcd31d84d7\" x=\"56.50625\" y=\"144.26845\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.225 -->\n",
       "      <g transform=\"translate(20.878125 148.067668) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path d=\"M 56.50625 117.614603 \n",
       "L 251.80625 117.614603 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbcd31d84d7\" x=\"56.50625\" y=\"117.614603\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 0.250 -->\n",
       "      <g transform=\"translate(20.878125 121.413822) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path d=\"M 56.50625 90.960757 \n",
       "L 251.80625 90.960757 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbcd31d84d7\" x=\"56.50625\" y=\"90.960757\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 0.275 -->\n",
       "      <g transform=\"translate(20.878125 94.759976) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-37\" d=\"M 525 4666 \n",
       "L 3525 4666 \n",
       "L 3525 4397 \n",
       "L 1831 0 \n",
       "L 1172 0 \n",
       "L 2766 4134 \n",
       "L 525 4134 \n",
       "L 525 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-37\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <path d=\"M 56.50625 64.306911 \n",
       "L 251.80625 64.306911 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbcd31d84d7\" x=\"56.50625\" y=\"64.306911\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 0.300 -->\n",
       "      <g transform=\"translate(20.878125 68.10613) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path d=\"M 56.50625 37.653065 \n",
       "L 251.80625 37.653065 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_20\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbcd31d84d7\" x=\"56.50625\" y=\"37.653065\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 0.325 -->\n",
       "      <g transform=\"translate(20.878125 41.452284) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <path d=\"M 56.50625 10.999219 \n",
       "L 251.80625 10.999219 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_22\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mbcd31d84d7\" x=\"56.50625\" y=\"10.999219\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 0.350 -->\n",
       "      <g transform=\"translate(20.878125 14.798438) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"222.65625\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_13\">\n",
       "     <!-- loss -->\n",
       "     <g transform=\"translate(14.798438 89.957031) rotate(-90) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-6c\" d=\"M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-73\" d=\"M 2834 3397 \n",
       "L 2834 2853 \n",
       "Q 2591 2978 2328 3040 \n",
       "Q 2066 3103 1784 3103 \n",
       "Q 1356 3103 1142 2972 \n",
       "Q 928 2841 928 2578 \n",
       "Q 928 2378 1081 2264 \n",
       "Q 1234 2150 1697 2047 \n",
       "L 1894 2003 \n",
       "Q 2506 1872 2764 1633 \n",
       "Q 3022 1394 3022 966 \n",
       "Q 3022 478 2636 193 \n",
       "Q 2250 -91 1575 -91 \n",
       "Q 1294 -91 989 -36 \n",
       "Q 684 19 347 128 \n",
       "L 347 722 \n",
       "Q 666 556 975 473 \n",
       "Q 1284 391 1588 391 \n",
       "Q 1994 391 2212 530 \n",
       "Q 2431 669 2431 922 \n",
       "Q 2431 1156 2273 1281 \n",
       "Q 2116 1406 1581 1522 \n",
       "L 1381 1569 \n",
       "Q 847 1681 609 1914 \n",
       "Q 372 2147 372 2553 \n",
       "Q 372 3047 722 3315 \n",
       "Q 1072 3584 1716 3584 \n",
       "Q 2034 3584 2315 3537 \n",
       "Q 2597 3491 2834 3397 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"27.783203\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"88.964844\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"141.064453\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_23\">\n",
       "    <path d=\"M 64.117655 -1 \n",
       "L 69.52625 54.157423 \n",
       "L 76.03625 88.683983 \n",
       "L 82.54625 117.09741 \n",
       "L 89.05625 122.739534 \n",
       "L 95.56625 122.728692 \n",
       "L 102.07625 124.086961 \n",
       "L 108.58625 121.446741 \n",
       "L 115.09625 118.684013 \n",
       "L 121.60625 119.565572 \n",
       "L 128.11625 118.254115 \n",
       "L 134.62625 125.110746 \n",
       "L 141.13625 125.443016 \n",
       "L 147.64625 126.125739 \n",
       "L 154.15625 125.023334 \n",
       "L 160.66625 121.560379 \n",
       "L 167.17625 122.311007 \n",
       "L 173.68625 121.913242 \n",
       "L 180.19625 124.877872 \n",
       "L 186.70625 125.015768 \n",
       "L 193.21625 123.026068 \n",
       "L 199.72625 122.174138 \n",
       "L 206.23625 119.538149 \n",
       "L 212.74625 124.293237 \n",
       "L 219.25625 121.208528 \n",
       "L 225.76625 116.221186 \n",
       "L 232.27625 122.715089 \n",
       "L 238.78625 125.480099 \n",
       "L 245.29625 125.041598 \n",
       "L 251.80625 121.702442 \n",
       "\" clip-path=\"url(#p2ec3af2ceb)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 56.50625 149.599219 \n",
       "L 56.50625 10.999219 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 251.80625 149.599219 \n",
       "L 251.80625 10.999219 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 56.50625 149.599219 \n",
       "L 251.80625 149.599219 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 56.50625 10.999219 \n",
       "L 251.80625 10.999219 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p2ec3af2ceb\">\n",
       "   <rect x=\"56.50625\" y=\"10.999219\" width=\"195.3\" height=\"138.6\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 350x250 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "trainer = torch.optim.RMSprop\n",
    "d2l.train_concise_ch11(trainer, {'lr': 0.01, 'alpha': 0.9},\n",
    "                       data_iter)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de5d0655",
   "metadata": {
    "origin_pos": 19
   },
   "source": [
    "## Summary\n",
    "\n",
    "* RMSProp is very similar to Adagrad insofar as both use the square of the gradient to scale coefficients.\n",
    "* RMSProp shares with momentum the leaky averaging. However, RMSProp uses the technique to adjust the coefficient-wise preconditioner.\n",
    "* The learning rate needs to be scheduled by the experimenter in practice.\n",
    "* The coefficient $\\gamma$ determines how long the history is when adjusting the per-coordinate scale.\n",
    "\n",
    "## Exercises\n",
    "\n",
    "1. What happens experimentally if we set $\\gamma = 1$? Why?\n",
    "1. Rotate the optimization problem to minimize $f(\\mathbf{x}) = 0.1 (x_1 + x_2)^2 + 2 (x_1 - x_2)^2$. What happens to the convergence?\n",
    "1. Try out what happens to RMSProp on a real machine learning problem, such as training on Fashion-MNIST. Experiment with different choices for adjusting the learning rate.\n",
    "1. Would you want to adjust $\\gamma$ as optimization progresses? How sensitive is RMSProp to this?\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ce477d8",
   "metadata": {
    "origin_pos": 21,
    "tab": [
     "pytorch"
    ]
   },
   "source": [
    "[Discussions](https://discuss.d2l.ai/t/1074)\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "required_libs": []
 },
 "nbformat": 4,
 "nbformat_minor": 5
}